﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Linq;
using WPFExcelReport.Helpers;
using System.Windows.Input;
using System.Windows.Controls;
namespace WPFExcelReport
{
    /// <summary>
    /// 专用于布卷剪布
    /// </summary>
    public partial class TWBDI2PR
    {
        public TWBDI2PR()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            InitializeComponent();
        }
        public override void NewCommand(object sender, RoutedEventArgs e)
        {
            if (dwAB == null)
            {
                MessageBox.Show("请选择一行织造单！");
                return;
            } 
            if (ROLLS == 0)
                return;
            if(Counts>0)
            {
                vwMaster.View.MoveCurrentToFirst();
            }
           
            while (true)
            {
                if (ROLLS == 0)
                    break;
                if (dwMaster == null)
                    break;
                if (BZ.Trim() != "")
                {
                    if (TMV.WBBVAR != BZ.Trim().PadRight(2))
                    {
                        vwMaster.View.MoveCurrentToNext();
                        if (vwMaster.View.IsCurrentAfterLast)
                            break;
                        continue;
                    }
                }
                dwMaster["WBBAUFKRS"] = dwAB["ABPAUFKRS"];
                dwMaster["WBBAUFLFD"] = dwAB["ABPAUFLFD"];
                dwMaster["WBBAUFPOS"] = dwAB["ABPAUFPOS"]; 
                TMV.UWB15(dwMaster);
                vwMaster.View.MoveCurrentToNext();
                if (vwMaster.View.IsCurrentAfterLast)
                    break;
                ROLLS--;
            }
            ROLLS = 0;
            BZ = "";
            string exauf = EXAUF;
            EXAUF = "";
            EXAUF = exauf;
            base.NewCommand(sender, e);
        }
    }
}
